from mpi4py import MPI
import numpy as np

comm = MPI.COMM_WORLD
rank = comm.Get_rank()

# initiate
rand_num = np.zeros(1)

if rank == 0:
    rand_num[0] = np.random.randint(10)

comm.Bcast(rand_num, root=0)
print(f"Process {rank}: random number is {rand_num[0]}")

